package com.api.shopapi.mapper;

import com.api.shopapi.entity.DishesPlanNightItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DishesPlanNightItemMapper {

    @Insert("insert into dishes_plan_night_item" +
            "(" +
            "DishesPlanNightItemCode," +
            "DishesPlanNightCode," +
            "DishesCode," +
            "DishesName" +
            ") " +
            "values" +
            "(" +
            "#{dishesPlanNightItem.DishesPlanNightItemCode}," +
            "#{dishesPlanNightItem.DishesPlanNightCode}," +
            "#{dishesPlanNightItem.DishesCode}," +
            "#{dishesPlanNightItem.DishesName}" +
            ")")
    int insert(@Param("dishesPlanNightItem") DishesPlanNightItem dishesPlanNightItem);

    @Delete("delete from dishes_plan_night_item where dishesPlanNightItemCode=#{dishesPlanNightItemCode}")
    int delete(@Param("dishesPlanNightItemCode") String dishesPlanNightItemCode);

    @Update("update dishes_plan_night_item" +
            " set" +
            " DishesCode=#{dishesPlanNightItem.DishesCode}" +
            " where " +
            " dishesPlanNightItemCode=#{dishesPlanNightItem.dishesPlanNightItemCode}")
    int update(@Param("dishesPlanNightItem") DishesPlanNightItem dishesPlanNightItem);

    @Select("select * from dishes_plan_night_item where dishesPlanNightItemCode=#{dishesPlanNightItemCode} limit 1")
    DishesPlanNightItem getByDishesPlanNightItemCode(@Param("dishesPlanNightItemCode") String dishesPlanNightItemCode);

    @Select("<script>" +
            "select * from dishes_plan_night_item where dishesPlanNightCode=#{dishesPlanNightCode} " +
            "</script>")
    List<DishesPlanNightItem> ListByDishesPlanNightCode(@Param("dishesPlanNightCode") String dishesPlanNightCode);

}
